package cn.chenc.framework.demo.config;

//import cn.chenc.framework.excel.config.CustomerDefaultConverterLoader;
import org.springframework.context.annotation.Configuration;

/**
 * 　@description: TODO
 * 　@author secret
 * 　@date 2021/2/27 12:57
 *
 */
@Configuration
//@AutoConfigureAfter(CustomerDefaultConverterLoader.class)
public class ExcelConfig {
//    //存放写时用到的converter
//    private static final String ALL_CONVERTER = "allConverter";
//    //存放所有的converter
//    private static final String WRITE_CONVERTER = "defaultWriteConverter";
//
//    @Bean
//    @Primary
//    public DefaultConverterLoader addConverter() throws IllegalAccessException {
//        DefaultConverterLoader converters = new DefaultConverterLoader();
//        Field[] fields = converters.getClass().getDeclaredFields();
//        for (Field field : fields) {
//            field.setAccessible(true);
//            if (field.getType() == Map.class) {
//                Map<String, Converter> oldMap = (Map<String, Converter>) field.get(converters);
//                if (oldMap != null && !oldMap.isEmpty()) {
//                    if (WRITE_CONVERTER.equalsIgnoreCase(field.getName())) {
//                        putWriteConverter(oldMap, new LocalDateTimeConverter());
//                        putAllConverter(oldMap,new NumberToLocalDateTimeConverter());
//                        putWriteConverter(oldMap, new MyLocalDateTimeConverter());
//                    } else if (ALL_CONVERTER.equalsIgnoreCase(field.getName())) {
//                        putAllConverter(oldMap, new LocalDateTimeConverter());
//                        putAllConverter(oldMap,new NumberToLocalDateTimeConverter());
//                        putWriteConverter(oldMap, new MyLocalDateTimeConverter());
//                    }
//                    field.set(converters, oldMap);
//                }
//            }
//        }
//        return converters;
//    }
//
//    private void putWriteConverter(Map<String, Converter> map, Converter converter) {
//        map.put(ConverterKeyBuild.buildKey(converter.supportJavaTypeKey()), converter);
//    }
//
//    private void putAllConverter(Map<String, Converter> map, Converter converter) {
//        map.put(ConverterKeyBuild.buildKey(converter.supportJavaTypeKey(), converter.supportExcelTypeKey()), converter);
//    }

}
